﻿using UnityEngine;
using System.Collections.Generic;

#if UNITY_EDITOR
using UnityEditor;
namespace WooEngine.Common
{
	[CustomEditor(typeof(ComponentRef))]
	public class ComponentRefInspector : Editor
	{
	    public override void OnInspectorGUI()
	    {
			DrawDefaultInspector();

			if (!EditorApplication.isPlaying)
			{
				if (GUILayout.Button("Remove None"))
				{
					ComponentRef self = (ComponentRef)target;
					List<GameObject> temp = new List<GameObject>();
					for (int i = 0; i < self.obj.Length; i++)
					{
						if (self.obj[i] != null)
						{
							temp.Add(self.obj[i]);
						}
					}
					self.obj = temp.ToArray();
				}
			}
	    }
	}
}
#endif

namespace WooEngine.Common
{
	[AddComponentMenu("WooEngine/ComponentRef", 1)]
	public class ComponentRef : MonoBehaviour {
	    public GameObject[] obj;

		public int GetSize(){
			return obj.Length;
		}
        
	}
}